﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SppPlan.aspx.cs" Inherits="Catering.yl.Daily.EMASppPlan"%>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title> 
    <script src="../../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../../Scripts/zhezhao.js" type="text/javascript"></script>
    <link href="../../../Style/ZHJG/zhezhao.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../../Style/head_2.css" />
    <link rel="stylesheet" type="text/css" href="../../../Style/center.css" />    
    <script language="javascript" type="text/javascript" src="../../../Scripts/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../../Scripts/uploader/jquery.uploadify.v2.1.0.min.js"></script>
    <script type="text/javascript" src="../../../Scripts/uploader/swfobject.js"></script>
    <link type="text/css" href="../../../Scripts/uploader/uploadify.css" rel="stylesheet" />
    <link href="../../../Style/sysData.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .bander{width:998px; border:1px solid #C2DEF6; background-color:#E5F1FD; height:34px; margin:10px auto 10px; line-height:34px;}
        .rbtj_report{text-align:center; clear:both;}
        .rbtj_report h1{ font-size:16px; margin:5px auto 10px;}
    </style>
    <script type="text/javascript">
        $(document).ready(function () {            
            $("#Imgfile_pType").uploadify({
                'uploader': '../../../Scripts/uploader/uploadify.swf',
                'script': '../../richang/Upload.aspx',
                'cancelImg': '../../../Scripts/uploader/cancel.png',
                'folder': '../../../UpFile',
                'queueID': 'fileQueue',
                'buttonImg': '../../../Scripts/uploader/liulan.png',
                'auto': false,
                'multi': true,
                'onComplete': function fun(event, queueID, fileObj, response, data) {
                    if (response == "true") {
                        alert("文件：" + fileObj.name + "上传成功。");
                        $("#hdn_pType_filepath").val($("#hdn_pType_filepath").val() + fileObj.name);
                    }
                    else if (response == "false") {
                        alert("文件上传出错！");
                    }
                },
                'onSelect': function (e, queueId, fileObj) {
                    $('#Imgfile_pType').uploadifyUpload();
                },
                'onCancel': function (file) {

                }
            });
        });
        function PAdd() {
            $("#txt_PName").val("");
            $("#txt_PType").val("");
            $("#txt_PUint").val(""); 
            $("#txt_PNums").val("");
            $("#txt_PRemark").val("");
            $("#hdn_pType_filepath").val("");
            $("#btnPEdit").hide();
            $("#btnPAdd").show();
            divshow("Pmain", "bg1");
        }
       
        function PEdit(cid) {
            $("#HidPID").val(cid);

            $.ajax({
                type: "Post",
                url: "SppPlan.aspx/PGet",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {                    
                    $("#txt_Pid").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_PName").val(data.d[1] == null ? "" : data.d[1]);
                    $("#txt_PType").val(data.d[2] == null ? "" : data.d[2]);
                    $("#txt_PUint").val(data.d[3] == null ? "" : data.d[3]);
                    $("#txt_PNums").val(data.d[4] == null ? "" : data.d[4]);
                    $("#txt_PRemark").val(data.d[5] == null ? "" : data.d[5]);
                    $("#hdn_pType_filepath").val("");

                    $("#btnPEdit").show();
                    $("#btnPAdd").hide();                    
                    divshow("Pmain", "bg1");
                }
            });
        }
        function btn_PAdd()
        {
            var txt_PName = $("#txt_PName").val();
            if (txt_PName == "") {
                alert("产品名称为空！");
                return;
            }
            var txt_PType = $("#txt_PType").val();
            //if (txt_PType == "") {
            //    alert("产品型号为空！");
            //    return;
            //}
            var txt_PUint = $("#txt_PUint").val();
            if (txt_PUint == "") {
                alert("计量单位为空！");
                return;
            }
            var txt_PNums = $("#txt_PNums").val();
            if (txt_PNums == "") {
                alert("产品数量为空！");
                return;
            }
            var txt_PRemark = $("#txt_PRemark").val();
            if (txt_PRemark == "") {
                alert("备注为空！");
                return;
            }
            var sel = document.getElementById("Drop_ZuoYeQu");
            var Drop_ZuoYeQu = sel.options[sel.selectedIndex].value;
            sel = document.getElementById("Drop_BanZu");
            var Drop_BanZu = sel.options[sel.selectedIndex].value;
             <%  string ddl_Mtc_val = "";
                if (ddl_Mtc.Items.Count != 0)
                    ddl_Mtc_val = ddl_Mtc.SelectedValue;               
            %>
            var ddl_Mtc = '<%=ddl_Mtc_val%>';
            if (ddl_Mtc == "") {
                alert("承包商为空，请添加！");
                return;
            }
            var txt_date = $("#txt_date").val();
            var hdn_pType_filepath = $("#hdn_pType_filepath").val();
            $.ajax({
                type: "Post",
                url: "SppPlan.aspx/PAdd",
                data: "{'AccessName':'" + txt_PName + "','ModelRuler':'" + txt_PType + "','AccessUnit':'" + txt_PUint + "','AccessNumber':'" + txt_PNums + "','ConDesc':'" + txt_PRemark + "','Drop_ZuoYeQu':'" + Drop_ZuoYeQu + "','Drop_BanZu':'" + Drop_BanZu + "','ddl_Mtc':'" + ddl_Mtc + "','txt_date':'" + txt_date + "','hdn_pType_filepath':'" + hdn_pType_filepath + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",

                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                    else
                    {
                        alert("请检查相应数据类型！");
                    }
                }
            });
        }
        //修改数据
        function btn_PEdit() {
            var txt_PName = $("#txt_PName").val();
            var txt_PType = $("#txt_PType").val();
            var txt_PUint = $("#txt_PUint").val();
            var txt_PNums = $("#txt_PNums").val();
            var txt_PRemark = $("#txt_PRemark").val();
            var cid = $("#txt_Pid").val();
            var sel = document.getElementById("Drop_ZuoYeQu");
            var Drop_ZuoYeQu = sel.options[sel.selectedIndex].value;
            sel = document.getElementById("Drop_BanZu");
            var Drop_BanZu = sel.options[sel.selectedIndex].value;            
            sel = document.getElementById("ddl_Mtc");
            var ddl_Mtc = sel.options[sel.selectedIndex].value;            
            var txt_date = $("#txt_date").val();
            var hdn_pType_filepath = $("#hdn_pType_filepath").val();
            $.ajax({
                type: "Post",
                url: "SppPlan.aspx/PEdit",
                data: "{'_id':'" + cid + "','AccessName':'" + txt_PName + "','ModelRuler':'" + txt_PType + "','AccessUnit':'" + txt_PUint + "','AccessNumber':'" + txt_PNums + "','ConDesc':'" + txt_PRemark + "','Drop_ZuoYeQu':'" + Drop_ZuoYeQu + "','Drop_BanZu':'" + Drop_BanZu + "','ddl_Mtc':'" + ddl_Mtc + "','txt_date':'" + txt_date + "','hdn_pType_filepath':'" + hdn_pType_filepath + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                    else {
                        alert("请检查相应数据类型！");
                    }
                }
            });
        }
     </script>
    <style type="text/css">
        .auto-style1 {
            width: 165px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
         <div class="xxk_button1">
        <ul>
            <li id="li4_1" class="li_out"><a href="../../richang/rbgl.aspx">填写日报</a> </li>
            <li id="li4_2" class="li_out"><a href="../../richang/rbtj.aspx">日报统计</a> </li>
            <li id="li4_3" class="li_out"><a href="ERepair.aspx">设备报修</a> </li>
            <li id="li4_4" class="li_out li_over"><a href="SppPlan.aspx">配件采购计划</a> </li>
        </ul>
       </div>
        <asp:HiddenField ID="HidPID" runat="server" />
            <div style="width: 100%;height: 30px;line-height: 30px;padding: 5px 0px;border: 1px solid #c2def6;background-color: #e5f1ff;margin-top: 10px; width:998px;margin:auto;">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr style="text-align:right">
                   <td style="width:50px">作业区:</td>
                    <td style="width:120px"><asp:DropDownList ID="Drop_ZuoYeQu" runat="server" AutoPostBack="True" CssClass="select_input_bg" Width="120px" OnSelectedIndexChanged="Drop_ZuoYeQu_SelectedIndexChanged"></asp:DropDownList></td>
                    <td style="width:50px">班组:</td>
                    <td style="width:120px"><asp:DropDownList ID="Drop_BanZu" runat="server" AutoPostBack="True" CssClass="select_input_bg" Width="120px" OnSelectedIndexChanged="Drop_BanZu_SelectedIndexChanged"></asp:DropDownList></td> 
                    <td style="width:50px">承包商:</td> 
                    <td style="width:120px"><asp:DropDownList ID="ddl_Mtc" runat="server" AutoPostBack="True" CssClass="select_input_bg" Width="120px" OnSelectedIndexChanged="ddl_Mtc_SelectedIndexChanged"></asp:DropDownList></td>
                    <td style="width:80px">添加时间:</td> 
                    <td style="width:100px"><asp:TextBox ID="txt_date" runat="server" Width="100px"></asp:TextBox></td>                                        
                    <td align="right" height="30">
                        <input type="button" class="input_btn_a" value="添加" onclick="PAdd()" />
                    </td>
                    <td width="10"></td>
                </tr>
            </table>
        </div>
        <div style="padding: 0px;text-align: center;height: 29px;">
            <table cellpadding="0" cellspacing="0" width="100%" style="border-left:1px solid #8b8888;border-top:1px solid #8b8888; width:998px;margin:auto;font-size:12px">
                <thead>
                    <tr style="background:url(../../../Images/th_02bg.gif) repeat-x 0px 0px; height:29px;">
                        <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888; width:80px">序号
                        </td >
                        <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888"  class="auto-style1">产品名称
                        </td>
                        <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888"  class="auto-style1">产品型号
                        </td>
                        <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888"  class="auto-style1">型号文档
                        </td>
                        <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888"  class="auto-style1">计量单位
                        </td>
                        <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888"  class="auto-style1">产品数量
                        </td>
                        <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888"  class="auto-style1">备注
                        </td>
                        <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888;width:50px">操作
                        </td>                        
                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="Rep_PPlan" runat="server" OnItemCommand="Rep_PPlan_ItemCommand">
                        <ItemTemplate>
                            <tr>
                                <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888">
                                    <%#Eval("tempId")%>                                    
                                </td>
                                <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888">
                                    <%#Eval("AccessName")%>
                                </td>
                                <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888">
                                    <%#Eval("ModelRuler")%>
                                </td>
                                <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888">
                                    <%# formatfilename(Eval("wendang").ToString())%>
                                </td>
                                <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888">
                                    <%#Eval("AccessUnit")%>
                                </td>
                                <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888">
                                    <%#Eval("AccessNumber")%>
                                </td>
                                <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888">
                                    <%#Eval("ConDesc")%>
                                </td>
                                <td style="border-right:1px solid #8b8888;border-bottom:1px solid #8b8888">
                                    <img alt="" title="编辑" src="../../../Images/file.gif" style="cursor: pointer;" onclick="PEdit('<%#Eval("id")%>')"/>
                                    <asp:ImageButton ToolTip="删除" ID="ImageButton1" runat="server" ImageUrl="../../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                        CommandArgument='<%#Eval("id")%>' CommandName="Pdel" />
                                </td>                                
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
        </div>
             <!--采购弹出层-->
        <div id="bg1" class="bg">
        </div>
        <div id="Pmain" class="center_div" style="width: 450px; height: 250px; margin:auto;left:25%;top:10%;">
            <div class="div_0207" style="width: 448px; height: 100%; margin: 0px;">
                <h1>
                    <img src="../../../Images/cp_h1_03.gif" />添加配件采购</h1>
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="80" height="30" align="right">产品名称：
                        </td>
                        <td width="110">   
                            <asp:HiddenField ID="txt_Pid" runat="server"/>                
                            <asp:TextBox ID="txt_PName" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>
                        </td>
                        <td width="80" height="30" align="right">产品型号：
                        </td>
                        <td width="110" height="30"> 
                            <asp:TextBox ID="txt_PType" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>                            
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="4">
                            <input type="hidden" id="hdn_pType_filepath"/>
                            <input type="file" id="Imgfile_pType" style="height:22px;vertical-align:middle;" />
                        </td>
                    </tr>
                    <tr style="height:30px">
                        <td width="80" height="30" align="right">单位：
                        </td>
                        <td width="110">                            
                            <asp:TextBox ID="txt_PUint" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>
                        </td>
                        <td width="80" height="30" align="right">数量：
                        </td>
                        <td width="110">                            
                            <asp:TextBox ID="txt_PNums" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">备  注：
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="txt_PRemark" runat="server" TextMode="MultiLine" CssClass="input_bg"
                                Style="width: 330px; height: 40px;"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <table width="100%">
                    <tr>
                        <td height="30" align="right">
                            <input type="button" id="btnPAdd" onclick="btn_PAdd()" class="input_btn_a" value="提交" />
                            <input type="button" id="btnPEdit" onclick="btn_PEdit()" class="input_btn_a" value="提交" />
                        </td>
                        <td>
                            <input type="button" id="but_PClose" onclick='divhidel("Pmain", "bg1")' class="input_btn_a"
                                value="关闭" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>         
       <!--弹出层培训情况   结束-->
    <iframe style="display:none;" id="frame_download" name="frame_download"></iframe>
    </form>
</body>
</html>
